package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.utils.uuid.UUID;
import com.ruoyi.system.domain.BiandongPici;
import com.ruoyi.system.service.IBiandongPiciService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 专家中心变动批次Controller
 * 
 * @author ruoyi
 * @date 2022-12-14
 */
@Controller
@RequestMapping("/system/biandongpici")
public class BiandongPiciController extends BaseController
{
    private String prefix = "system/biandongpici";

    @Autowired
    private IBiandongPiciService biandongPiciService;

    @RequiresPermissions("system:biandongpici:view")
    @GetMapping()
    public String biandongpici()
    {
        return prefix + "/biandongpici";
    }

    /**
     * 查询专家中心变动批次列表
     */
    @RequiresPermissions("system:biandongpici:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BiandongPici biandongPici)
    {
        startPage();
        List<BiandongPici> list = biandongPiciService.selectBiandongPiciList(biandongPici);
        return getDataTable(list);
    }

    /**
     * 导出专家中心变动批次列表
     */
    @RequiresPermissions("system:biandongpici:export")
    @Log(title = "专家中心变动批次", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BiandongPici biandongPici)
    {
        List<BiandongPici> list = biandongPiciService.selectBiandongPiciList(biandongPici);
        ExcelUtil<BiandongPici> util = new ExcelUtil<BiandongPici>(BiandongPici.class);
        return util.exportExcel(list, "专家中心变动批次数据");
    }

    /**
     * 新增专家中心变动批次
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存专家中心变动批次
     */
    @RequiresPermissions("system:biandongpici:add")
    @Log(title = "专家中心变动批次", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BiandongPici biandongPici)
    {
        biandongPici.setPiciid(UUID.randomUUID().toString());
        biandongPici.setBiandongrenshu((long)0);
        biandongPici.setIsvalid((long)1);
        return toAjax(biandongPiciService.insertBiandongPici(biandongPici));
    }

    /**
     * 修改专家中心变动批次
     */
    @RequiresPermissions("system:biandongpici:edit")
    @GetMapping("/edit/{piciid}")
    public String edit(@PathVariable("piciid") String piciid, ModelMap mmap)
    {
        BiandongPici biandongPici = biandongPiciService.selectBiandongPiciByPiciid(piciid);
        mmap.put("biandongPici", biandongPici);
        return prefix + "/edit";
    }

    /**
     * 修改保存专家中心变动批次
     */
    @RequiresPermissions("system:biandongpici:edit")
    @Log(title = "专家中心变动批次", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BiandongPici biandongPici)
    {
        return toAjax(biandongPiciService.updateBiandongPici(biandongPici));
    }

    /**
     * 删除专家中心变动批次
     */
    @RequiresPermissions("system:biandongpici:remove")
    @Log(title = "专家中心变动批次", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(biandongPiciService.deleteBiandongPiciByPiciids(ids));
    }
}
